//
//  OAMainVC.m
//  OA项目
//
//  Created by innofive on 2018/4/12.
//  Copyright © 2018年 inno. All rights reserved.
//

#import "OAMainVC.h"
#import "OANoticeListVC.h"
#import "OAFinancialTableVC.h"
#import "OAFinancialTable2VC.h"
#import "OAPageApproveVC.h"
@interface OAMainVC ()<SDCycleScrollViewDelegate>
@property(nonatomic,strong)NSMutableArray *notifis;
@end

@implementation OAMainVC

- (void)viewDidLoad {
    [super viewDidLoad];
    
}

-(void)onLoadDataForPageNum:(NSInteger)pageNum
{
    WSELF(weakSelf);
    [OANoticeListModel onPOSTParam:@{@"startPageNo":@"1",
                                     @"numberOfOnePage":@"10",
                                     @"isOnlyNeedActiveNt":@"",
                                     @"searchKey":@"",
                                     } successBlock:^(id data) {
                                         [weakSelf.notifis removeAllObjects];
                                         [weakSelf.notifis addObjectsFromArray:data];
                                         [weakSelf.tableView reloadSections:[NSIndexSet indexSetWithIndex:1] withRowAnimation:(UITableViewRowAnimationNone)];
                                        
                                     } falieBlock:self.failedListBlock errorBlock:self.errorListBlock];

}


#pragma mark 点击方法
/** 点击图片回调 */
- (void)cycleScrollView:(SDCycleScrollView *)cycleScrollView didSelectItemAtIndex:(NSInteger)index
{
}
-(void)onClickButton:(UIButton *)button
{
    if (button.tag==10) {
        [self onClickHeaderView:nil];
    }
    else if(button.tag==11)
    {
    
        OAPageApproveVC *vc =[OAPageApproveVC new];
        vc.title = @"审批管理";
        [self pushToVC:vc model:nil hideTabBar:YES];
        
    }
    else if(button.tag==12)
    {
        OAFinancialTable2VC *vc =[[OAFinancialTable2VC alloc]init];
        vc.title = @"财务报表";
        [self pushToVC:vc model:nil hideTabBar:YES];
        
    }
    else
    {
        OAFinancialTableVC *vc =[[OAFinancialTableVC alloc]initWithStyle:(UITableViewStyleGrouped)];
        vc.title = @"利润表";
        vc.type = openVCTypeOne;
        [self pushToVC:vc model:nil hideTabBar:YES];
    }
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.section==1) {
        OAWebVC *vc =[OAWebVC new];
        vc.title = @"公告详情";
        vc.url = @"http://wwww.baidu.com";
        [self pushToVC:vc model:nil hideTabBar:YES];
    }
    
}
-(void)onClickHeaderView:(UITapGestureRecognizer *)tapGestureRecognizer
{
    OANoticeListVC *vc= [[OANoticeListVC alloc]initWithStyle:(UITableViewStylePlain)];
    vc.title = @"通知公告";
    [self pushToVC:vc model:nil hideTabBar:YES];
}
#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 2;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    if (section==0) {
        return 1;
    }
    return self.notifis.count;
}

-(MCCellInfo *)tableView:(UITableView *)tableView cellForIndexPath:(NSIndexPath *)indexPath IsHeight:(BOOL)isheight
{
    if (indexPath.section==0) {
        return [MCCellInfo configForCellId:cell Class:[OAMainCell class] Height:kFitH(100) TableView:tableView];
      
    }
    return [MCCellInfo configForCellId:cell1 Class:[OAMainCell1 class] Height:kFitH(50) TableView:tableView CellStyle:UITableViewCellStyleValue1];
   
}

-(MCHFViewInfo *)tableView:(UITableView *)tableView HeaderInSection:(NSInteger)section isBiao:(BOOL)isBiao
{
    if (section==0) {
    return [MCHFViewInfo configForViewId:header Class:[OAMainHeaderFooterView class] Height:kFitH(200) TableView:tableView IsBian:NO];
    }
  return [MCHFViewInfo configForViewId:header1 Class:[OAMainHeaderFooterView1 class] Height:kFitH(40) TableView:tableView IsBian:NO];
}


-(MCHFViewInfo *)tableView:(UITableView *)tableView FooderInSection:(NSInteger)section isBiao:(BOOL)isBiao
{
    if (section==0) {
        return [MCHFViewInfo configForViewId:foodter Class:[BaseTableViewHeaderFooterView class] Height:kFitH(10) TableView:tableView IsBian:NO];
    }
    return nil;
}

-(id)modelForIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.section==1) {
        return self.notifis[indexPath.row];
    }
    return nil;
}


-(NSMutableArray *)notifis
{
if(!_notifis)
{
    _notifis = [NSMutableArray array];
}
    return _notifis;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
